package cn.fastoo.web.backstage.web.controller.oa;

import cn.fastoo.common.sampleframe.dto.JsonResult;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping("/oa")
public class OAController {
	/**
	 * 1.查询所有能工作流 deployment.
	 * 2.启动一个工作流 task.
	 * 3.设置一个工作流 task.
	 * 4.执行一个工作流 task
	 */

	@Autowired
	private ProcessEngine processEngine;

	@RequestMapping("/getTaskById")
	public String index(String id) {
		List<Task> tasks = processEngine.getTaskService().createTaskQuery().taskCandidateUser("id").list();
		return JsonResult.success(tasks);
	}

	@RequestMapping("/orderByDeploymenTime")
	@ResponseBody
	public String start() {
		processEngine.getRepositoryService().createDeploymentQuery().orderByDeploymenTime();
		return JsonResult.success(processEngine.getRepositoryService().createDeploymentQuery().orderByDeploymenTime());
	}



}
